package com.hellojava.dto;


import com.hellojava.util.StringUtil;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * Created by linyh on 2017/7/12.
 */
public abstract class Dto implements Serializable{

    protected String blankWhenNull(Object o){
        return o == null ? null : o.toString();
    }

    protected Integer blankWhenNullOfInteger(Object o){
        return o != null && StringUtil.isNotNil(o.toString()) ? Integer.parseInt(o.toString()) : null;
    }


    protected Date blankWhenNullOfDate(Object o){
        return o == null ? null : (Date)o;
    }


    protected BigDecimal blankWhenNullOfBigDecimal(Object o) {
        return o == null ? null : new BigDecimal(o.toString());
    }

}
